package cn.monkey.chat.server.admin.domain.account;

import cn.monkey.chat.server.data.Result;
import cn.monkey.chat.server.data.account.Account;
import cn.monkey.chat.server.data.account.AccountCreateReq;
import cn.monkey.chat.server.data.account.Authorization;
import cn.monkey.chat.server.data.account.SignInReq;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

@RestController
@RequestMapping("account")
public class AccountController {
    final IAccountService accountService;

    public AccountController(IAccountService accountService) {
        this.accountService = accountService;
    }

    @PostMapping("signIn")
    public Mono<Result<Authorization>> signIn(SignInReq req) {
        return this.accountService.signIn(req);
    }

    @PostMapping("create")
    public Mono<Result<Account>> create(AccountCreateReq req) {
        return this.accountService.create(req);
    }
}
